package com.xy.biz.ts.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.ts.domain.bo.TrainSumBO;
import com.xy.biz.ts.domain.po.TrainSumPO;
import com.xy.biz.ts.domain.query.TrainSumQuery;
import com.xy.biz.ts.domain.resp.GetTrainSumResponse;
import com.xy.biz.ts.domain.req.SaveTrainSumRequest;
import com.xy.biz.ts.domain.req.ListTrainSumRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-7-29
 */
public class TrainSumConverter {
	
	public static TrainSumPO toPO(TrainSumBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TrainSumPO(), true);
	}
	
	public static List<TrainSumPO> toPO(Collection<TrainSumBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TrainSumPO(), true);
	}
	
	public static TrainSumBO fromPO(TrainSumPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new TrainSumBO());
	}
	
	public static List<TrainSumBO> fromPO(Collection<TrainSumPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TrainSumBO());
	}
	
	public static TrainSumBO toBO(SaveTrainSumRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new TrainSumBO(), true);
	}
	
	public static List<TrainSumBO> toBO(Collection<SaveTrainSumRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new TrainSumBO(), true);
	}
	
	public static GetTrainSumResponse toResponse(TrainSumBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetTrainSumResponse());
	}
	
	public static List<GetTrainSumResponse> toResponse(Collection<TrainSumBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetTrainSumResponse());
	}
	
	public static TrainSumQuery toQuery(ListTrainSumRequest source) {
		if(null == source) {
			return null;
		}
		TrainSumQuery target = new TrainSumQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
